home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 1999 January / CD Rom Data Ocak 1999.iso / Xtras / QT3 Behavior Library.cst / 00002_pointAtSprite.ls next >
Encoding:
Text File  |  1998-04-19  |  1.7 KB  |  69 lines

  1. -- pointAtSprite
  2.  
  3.  
  4. --Points a QT3 sprite at any other Director sprite. 
  5. --
  6. --PARAMETERS: 
  7. --
  8. --Point at sprite - Specify the channel # of the sprite to point at 
  9. --
  10. --NOTE: Assumes QT3 sprite points left to right --> when angle is 0.0 
  11.  
  12. property pointAtSpriteNum
  13.  
  14. on prepareFrame me
  15.   
  16.   -- note, to point at an arbitrary point, substitute 'the loch of sprite pointAtSpriteNum'
  17.   -- and 'the locv of sprite pointAtSpriteNum' with the coords to point at
  18.   
  19.   -- determine slope
  20.   set deltah = the loch of sprite pointAtSpriteNum - the loch of sprite the spritenum of me
  21.   set deltav = the locv of sprite pointAtSpriteNum - the locv of sprite the spritenum of me  
  22.   
  23.   -- determine angle given slope
  24.   if deltah <> 0 then
  25.     set slope = (deltav + 0.0) / (deltah) + 0.0
  26.     set angle = atan(slope) * 180.0 / pi
  27.     if deltah < 0 then
  28.       set angle = angle + 180.0
  29.     end if
  30.   else
  31.     if deltav > 0 then
  32.       set angle = 90.0
  33.     else
  34.       set angle = 270.0
  35.     end if
  36.   end if
  37.   
  38.   -- set the new rotation
  39.   set tempRotation = the rotation of sprite the spritenum of me
  40.   
  41.   if tempRotation <> angle then
  42.     set the rotation of sprite the spritenum of me to angle
  43.   end if
  44. end
  45.  
  46.  
  47.  
  48. ---
  49.  
  50. on getPropertyDescriptionList
  51.   
  52.   set p_list = [ ┬¼
  53.    #pointAtSpriteNum: [ #comment:  "Point at sprite in channel:", ┬¼
  54.                         #format:   #integer, ┬¼
  55.                         #default:   1 ] ┬¼
  56.                ]
  57.   return p_list  
  58.   
  59. end
  60.  
  61. on getBehaviorDescription
  62.   return ┬¼
  63. "Points a QT3 sprite at any other Director sprite." && RETURN & RETURN &┬¼
  64. "PARAMETERS:" && RETURN &┬¼
  65. "Point at sprite - Specify the channel # of the sprite to point at" && RETURN & RETURN & ┬¼
  66.   "NOTE: Assumes QT3 sprite points left to right --> when angle is 0.0" && RETURN
  67.   
  68. end
  69.